home *** CD-ROM | disk | FTP | other *** search
- #include <stdio.h>
- #include <io.h>
- main()
- {
- char fname[40], *p_fname;
- int filehandle;
- printf("Enter name of file to creat using"
- "_creat:");
- p_fname = gets(fname);
-
- /* Creat the file using _creat */
- if ( (filehandle = _creat(p_fname, 0)) == -1)
- {
- perror("Error creating file");
- exit(0);
- }
- printf("File %s created. \n", fname);
-
- /* Now close file */
- if(_close(filehandle) != 0)
- {
- perror("Error closing file with _close");
- exit(0);
- }
- printf("File %s closed. \n", fname);
- }